<template>
    <div v-loading="!isShow">
        <div class="zs-card-sm zs-space-bottom zs-layout-flex-row">
            <el-select v-model="biProjectCode" class="zs-select-md zs-space-right-sm" placeholder="项目名称" @change="changeProject()">
                <el-option v-for="item in projectList" :key="item.biProjectCode" :label="item.projectName"
                    :value="item.biProjectCode" />
            </el-select>
        </div>
        <el-scrollbar class="db-content-height" v-if="isShow">
            <div class="db-content-cards">
                <BaseInfo :biProjectCode="biProjectCode" :projectCode="projectCode" :permi="tabPermi"></BaseInfo>
                <!-- 营业额 -->
                <RestaurantTurnover :permi="'p_btn_901_jingyingcanyin_xiangqing_yingyee'" :hideList="hideList" :biProjectCode="biProjectCode" :updateDate="updateDate"></RestaurantTurnover>
                <!-- 上座率 -->
                <Seat :permi="'p_btn_901_jingyingcanyin_xiangqing_sahngzuolv'" :hideList="hideList" :biProjectCode="biProjectCode" :updateDate="updateDate"></Seat>
                <!-- 人均消费 -->
                <AvgConsume :permi="'p_btn_901_jingyingcanyin_xiangqing_rjxf'" :hideList="hideList" :biProjectCode="biProjectCode" :updateDate="updateDate"></AvgConsume>
                <!-- 预算对标 -->
                <BudgetcAhievement :permi="'p_btn_901_jingyingcanyin_xiangqing_ysdb'" :hideList="hideList" :biProjectCode="biProjectCode" :updateDate="updateDate"></BudgetcAhievement>
                <!-- 财务-开办费 -->
				<FinanceKaiBanFei :permi="'p_btn_901_canyin_xiangqing_startupexpenses'" :subjectType="4" :hideList="hideList" :biProjectCode="biProjectCode" :biProjectName="biProjectName" :yearmonth="yearmonth"> </FinanceKaiBanFei>
				<!-- 财务-利润率 -->
				<FinanceLiRunBiao :permi="'p_btn_901_canyin_xiangqing_commercialprofit'" :subjectType="3" :hideList="hideList" :biProjectCode="biProjectCode" :biProjectName="biProjectName" :yearmonth="yearmonth"> </FinanceLiRunBiao>
				<!-- 财务-投入产出表 -->
				<FinanceTouRuChanChu :permi="'p_btn_901_canyin_xiangqing_lnputoutput'" :subjectType="2" :hideList="hideList" :biProjectCode="biProjectCode" :biProjectName="biProjectName" :yearmonth="yearmonth"> </FinanceTouRuChanChu>
				<!-- 财务-资金来源占用表 -->
				<FinanceZiJinLaiYuanZhanYong :permi="'p_btn_901_canyin_xiangqing_sourceandfunds'" :hideList="hideList" :biProjectCode="biProjectCode" :biProjectName="biProjectName" :yearmonth="yearmonth"> </FinanceZiJinLaiYuanZhanYong>
            </div>
        </el-scrollbar>
    </div>
</template>
<script setup>

import BaseInfo from '@/views/Manage/Business/components/baseInfo'
import RestaurantTurnover from '@/views/Manage/Restaurant/components/restaurantTurnover'
import Seat from '@/views/Manage/Restaurant/components/restaurantSeat'
import AvgConsume from '@/views/Manage/Restaurant/components/avgConsume'
import BudgetcAhievement from '@/views/Manage/Business/components/budgetcAhievement'
import FinanceKaiBanFei from '@/views/Manage/Business/components/financeKaiBanFei.vue'
import FinanceLiRunBiao from '@/views/Manage/Business/components/financeLiRunBiao.vue'
import FinanceTouRuChanChu from '@/views/Manage/Business/components/financeTouRuChanChu.vue'
import FinanceZiJinLaiYuanZhanYong from '@/views/Manage/Business/components/financeZiJinLaiYuanZhanYong.vue'

import dbPublicApi from '@/api/dbPublic'

import { ref } from 'vue'
import { useRoute } from 'vue-router'
const route = useRoute().query
let biProjectCode = ref(route.biProjectCode)
const projectCode = ref(route.projectCode)
const updateDate = route.updateDate
const tabPermi = route.tabPermi


let isShow = ref(false)
let hideList = ref([])
let projectList = ref([])
let biProjectName = ref('');
const getHide = async () => {
    await dbPublicApi.queryMenuHidePcApi(biProjectCode.value).then((res) => {
        if (res.data.code == 200) {
            hideList.value = res.data.data
        }
    })
}
const getList = () => {
    dbPublicApi.queryProjectPcApi({ dataTime: updateDate, resourceKey: tabPermi }).then((res) => {
        if (res.data.code == 200) {
            projectList.value = res.data.data
            let target = projectList.value.find(item => {
                return item.biProjectCode == biProjectCode.value;
            });
            biProjectName.value = target ? target.projectName : '';
        }
    })
}
const changeProject = async () => {
    isShow.value = false
    await getHide()
    const index = projectList.value.findIndex(item => {
        return item.biProjectCode == biProjectCode.value
    })
    projectCode.value = projectList.value[index].projectCode
    biProjectName.value = projectList.value[index].projectName;
    isShow.value = true
}

const yearmonth = ref()	
// 获取商业数据更新日期 年月 用于数字月报筛选
const queryDataUpdateTime = async () => {
    await dbPublicApi.queryMonthsTimeApi().then(res=>{
        let resData = res.data
        if(resData.code == 200){
            yearmonth.value = resData.data
        }
    })
}

const init = async () => {
    await queryDataUpdateTime()
    isShow.value = false
    await getHide()
    getList()
    isShow.value = true
}
init()

// echat 柱图数据
// const echatData = ref({
//     "xData": ["4.13", "4.15", "4.16", "4.17", "4.18", "4.19", "4.20", "4.21"],
//     "xLable": ["4月14日", "4月15日", "4月16日", "4月17日", "4月18日", "4月19日", "4月20日", "4月21日"],
//     "yData": [
//         {
//             "name": "当年",
//             "type": "bar",  // 当前内容显示的图形类型
//             "data": [30, 60, 20, 50, 30, 80, 100, 120],
//             "unit": "%", // 当前内容百分比的单独加单位字段。默认没有单位。data中不能出现%
//             "isShow": true, // 当前内容是否显示 true表示在图表中绘制，false代表只在提示框出现
//             "color": '#ED1A2C' // 代表当前图形颜色 默认不需要传，特殊需求的需要。比如环形图
//         },
//         {
//             "name": "当周日均",
//             "type": "bar",
//             "data": [120, 200],
//             "isShow": false
//         },
//         {
//             "name": "同比上周",
//             "type": "bar",
//             "data": [20, 40],
//             "unit": "%",
//             "isShow": false
//         }
//     ]
// })

</script>

<style scoped lang="scss"></style>
